<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>任务首页 - 科帮网</title>
    <meta name="author" content="小柒2012" />
    <meta name="site" content="https://blog.52itstyle.com" />
    <link rel="stylesheet" th:href="@{/iview/iview.css}">
    <script th:src="@{/libs/jquery-3.2.1.min.js}" type="text/javascript"></script>
    <script th:src="@{/libs/vue.min.js}" type="text/javascript"></script>
    <script th:src="@{/layer/layer.js}" type="text/javascript"></script>
    <script th:src="@{/iview/iview.min.js}" type="text/javascript"></script>
    <style type="text/css">
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak style="margin: 30px">
    <template>
        <i-form v-ref:form-user :model="userEntity" :rules="ruleValidate" :label-width="80">
            <Form-item label="uid" prop="uid">
                <i-input  v-model="userEntity.uid"  :value.sync="userEntity.uid" placeholder="uid"></i-input>
            </Form-item>
            <Form-item label="手机号" prop="mobile" >
                <i-input  v-model="userEntity.mobile" :value.sync="userEntity.mobile" placeholder="手机号"></i-input>
            </Form-item>
            <Form-item label="资产" prop="assetbalance">
                <i-input  v-model="userEntity.assetbalance" :value.sync="userEntity.assetbalance" placeholder="资产"></i-input>
            </Form-item>
            <Form-item label="积分" prop="score">
                <i-input v-model="userEntity.score" :value.sync="userEntity.score" placeholder="积分"></i-input>
            </Form-item>
            <Form-item label="Q宝" prop="qbao">
                <i-input v-model="userEntity.qbao" :value.sync="userEntity.qbao" placeholder=""></i-input>
            </Form-item>
        </i-form>
    </template>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el : '#app',
        data : {
            userEntity: {
                uid : '',
                mobile : '',
                assetbalance : '',
                score : '',
                qbao : ''
            },
            ruleValidate: {//非空验证
                uid: [
                    { required: true, message: 'uid不能为空', trigger: 'blur' }
                ],
                mobile: [
                    { required: true, message: '手机号不能为空', trigger: 'blur' }
                ],
                assetbalance: [
                    { required: true, message: '资产不能为空', trigger: 'blur' }
                ],
                score: [
                    { required: true, message: '积分不能为空', trigger: 'blur' }
                ],
                qbao: [
                    { required: true, message: 'qbao不能为空', trigger: 'blur' }
                ]
            }
        },
        methods : {
            //新建任务(略简单)
            editClick : function(){
                //Validate不起作用MD
                var user =  vm.userEntity;
                if(vm.userEntity.uid==""||vm.userEntity.mobile==""||vm.userEntity.assetbalance==""
                    ||vm.userEntity.score==""||vm.userEntity.qbao==""){
                    alert("请输入以上完整信息");
                    return;
                }
                /**post提交的对象,只有查询的字段有属性，其他没有查询出来的属性，没有字段。
                 * userid: 1
                 uid: 100001
                 username: admin
                 truename:
                 password:
                 paypassword:
                 mobile: 13192023272
                 address:
                 tuijian:
                 tuijiannum: 3
                 assetbalance: 14250
                 freezeassetbalance: 97995.05
                 reassetbalance: 0
                 score: 23064.93
                 tdnum: 66333
                 freezetdnum:
                 shifang:
                 email:
                 status:
                 grade:
                 regtime:
                 updatetime:
                 logintime:
                 loginip:
                 cashdeposit:
                 btcnum:
                 freezebtcnum:
                 ltcnum:
                 freezeltcnum:
                 ethnum:
                 freezeethnum:
                 startTime:
                 endTime:
                 daishu:
                 frezzstoreincome:
                 storeincome:
                 qbao: 100
                 frezzeqbao:
                 qbaograde:
                 qbaoscore:
                 cflbnum:
                 _index: 0
                 _rowKey: 1
                 JSON.stringify(user)//对象会接受到  _index: 0, _rowKey无法解析,为什么别人写的解析就正确了？
                 用
                 datatype:'json',
                 data:user 请求方法的时候有问题。
                 * */
                console.log(user);
                $.ajax({
                    type: "POST",
                    url:"../user/douseredit",
                    dataType:'json',
                    data:{"uid":user.uid,
                    "qbao":user.qbao} ,//须将对象转换为JSON?这样后台才能接收对象,以前一直是提交属性，没提交过对象，要么post提交表单，没有直接提交过对象
                    success: function(result) {
                        if(result.code=="0"){
                            window.parent.location.reload();
                        }else{
                            vm.$Notice.error({
                                desc:  '系统异常'
                            });
                        }
                    }
                });
            }
        },
        created : function() {

        }
    })

</script>
</body>
</html>